<?php

use think\facade\Route;

/** 接口路由 */

/* 课程信息 - 无需登录 */
Route::group('base', function () {
    Route::get('/list$', 'getCourseList');   // 课程列表
    Route::get('/search$', 'searchTitle');     // 通用搜索
    Route::get('/search/hot$', 'hotSearch');       // 热门搜索
    Route::get('category/tree$', 'getCategoryTree'); // 分类
    Route::get('type$', 'getOpenType');     // 客户已开通课程类型
    Route::post('courseware/record', 'saveCourseWareRecord');            // 记录用户课件下载
    // 单课程
    Route::group('<id>', function () {
        Route::get('$', 'getCourseDetails');            // 课程详情
        Route::get('splendid$', 'getCourseSplendid');            // 课程详情推荐课程
        Route::get('section/<pid>', 'getCourseAppointSections');    // 课程指定目录子集
        Route::get('section/<sid>/fileurl', 'getCourseSectionFileurl');     // 课时fileurl
        Route::get('section/<sid>/video/<stock>', 'getCourseSectionVideoYunParam');     // 课时视频云端参数
        Route::get('question', 'getCourseQuestion');            // 课程详情弹题
        Route::get('courseware', 'getCourseWare');            // 课程课件列表
    })->pattern(['id' => '\d+', 'pid' => '\d+', 'sid' => '\d+']);
})->prefix('\app\course\service\base\Course@')->middleware(['withoutLogin']);

/* 课时是否解锁 */
Route::get('unlock', '\app\course\service\base\Course@isCourseSecUnlock');

/** 课程学员后台接口 */
Route::group('admin/<course_id>/student', function () {
    // 添加学员
    Route::post('$', '@addStudent');
    Route::post('import', '@importStudent');
})->prefix('\app\course\service\base\admin\CourseStudent')->middleware(['adminRoute'])->pattern(['course_id' => '\d+']);

/** 课程后台接口 */
Route::group('admin/<course_id>', function () {
    // 添加学员
    Route::post('copy', '@copyCourseInfo');
})->prefix('\app\course\service\base\admin\Course')->middleware(['adminRoute'])->pattern(['course_id' => '\d+']);

Route::get('/ordertest$', 'app\course\logic\payment\PaymentOrder@createFalseOrder')->middleware(['withoutLogin', 'apiTest']);   // 测试

/** 课程通用管理接口 */
Route::group('admin', function () {
    Route::put('batch/updated/<field>', '@batchUpdatedField')->pattern(['field' => '[a-zA-Z_]+']);
    // 获取选择的课程列表
    Route::get('choose/courseList', '@getCourseList');
    // 批量获取课程详情
    Route::get('batch/info', '@getCourses');
    // 批量取消推荐课程
    Route::put('batch/cancel/recommend', '@cancelRecommend');
})->prefix('\app\course\service\base\admin\Course')->middleware(['adminRoute']);
